/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package genomemap.data;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;

/**
 *
 * @author stewari1
 */
@Entity
public class RFLPImputation implements Serializable {

    /**
     * corresponds to no imputation policy OF REMOVING ALL infected progeny
     */
    @Transient
    public static final int POLICY_REMOVE = 0;

    /**
     * If the missing value is surrounded by either 0 or 1
     * ,it is replaced by the same. On the other hand, if surrounded
     * by both 0 and 1, a coin is flipped and 0 is chosen with a certain
     *  probability termed as "imputationProb".
     */
    @Transient
    public static final int POLICY_PROB = 1;

    /** Field description */
    private int policyIndex = 0;

    /** Field description */
    private double imputationProb = 0.5;

    /**
     * Missing Value in the RFLP Data
     */
    private int missingValueCode = 9;

    /**
     * id .
     */
    @Id
    @GeneratedValue
    protected Long id;

    /**
     * Constructs ...
     */
    public RFLPImputation() {}

    /**
     * Constructs ...
     *
     * @param policyIndex description
     */
    public RFLPImputation(int policyIndex) {
        setPolicyIndex(policyIndex);
    }

    @Override
    public int hashCode() {

        return super.hashCode() + new Integer(policyIndex).hashCode()
               + new Double(imputationProb).hashCode();
    }

    /**
     * Note that <CODE>optionalOperModel</CODE> is not included in the <CODE>hashCode</CODE>
     * and <CODE>equals</CODE> implementation. This is to differentiate between the
     * core input setings that would require a fresh LHood computation from optional
     * operations which do not require a fresh LHood computation except for few
     * (SE computation if the accuracy wasn`t up to the required level).
     */
    @Override
    public boolean equals(Object obj) {

        if (obj instanceof RFLPImputation) {

            RFLPImputation rflpImputation = (RFLPImputation) obj;

            return (this.getPolicyIndex() == rflpImputation.getPolicyIndex())
                   && (this.getImputationProb() == rflpImputation.getImputationProb());
        }

        return false;
    }

    public int getPolicyIndex() {
        return policyIndex;
    }

    public void setPolicyIndex(int policyIndex) {
        this.policyIndex = policyIndex;
    }

    public double getImputationProb() {
        return imputationProb;
    }

    public void setImputationProb(double imputationProb) {
        this.imputationProb = imputationProb;
    }

    public int getMissingValueCode() {
        return missingValueCode;
    }

    public void setMissingValueCode(int missingValueCode) {
        this.missingValueCode = missingValueCode;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
